#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tkinter as tk
from tkinter import simpledialog

class WinBox(tk.simpledialog.Dialog):
    def __init__(self, parent, title, msg):
        self.my_username = None
        self.msg = msg
        super().__init__(parent, title)

    def body(self, frame):
        # print(type(frame)) # tkinter.Frame
        self.label = tk.Label(frame,  text=self.msg)
        self.label.pack()
        self.my_username_box = tk.Entry(frame,)
        self.my_username_box.pack()
        return frame

    def enter_pressed(self):
        # print("ok")
        self.my_username = self.my_username_box.get()
        print(self.my_username)
        self.destroy()

    def enter_play_again_pressed(self):
        # print("cancel")
        print('play again')
        self.destroy()


    def buttonbox(self):
        self.ok_button = tk.Button(self, text='Enter', command=self.enter_pressed)
        self.ok_button.pack(side="left")
        cancel_button = tk.Button(self, text='Enter and play again',  command=self.enter_play_again_pressed)
        cancel_button.pack(side="right")
        # self.bind("<Return>", lambda event: self.enter_pressed())
        # self.bind("<Escape>", lambda event: self.enter_play_again_pressed())

